<template>
  <div>
    <BasicTable @register="registerTable" />
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';

  import { BasicTable, useTable } from '/@/components/Table';
  import { getUserLoginLog } from '/@/api/system/system';
  import { columns, searchFormSchema } from './log.data';

  export default defineComponent({
    name: 'UserLoginLog',
    components: {
      BasicTable,
    },
    setup() {
      const [registerTable, { reload }] = useTable({
        title: '登录日志',
        api: getUserLoginLog,
        columns,
        formConfig: {
          labelWidth: 120,
          schemas: searchFormSchema,
        },
        beforeFetch: (params) => {
          params.startTime = params.createTime ? params.createTime[0] : '';
          params.endTime = params.createTime ? params.createTime[1] : '';
          return params;
        },
        useSearchForm: true,
        showTableSetting: true,
        bordered: true,
        showIndexColumn: false,
      });

      function handleSuccess() {
        reload();
      }

      return {
        registerTable,
        handleSuccess,
      };
    },
  });
</script>
